package cn.bdqn.controller;

import cn.bdqn.pojo.AppInfo;
import cn.bdqn.service.AppInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("appinfo")
public class AppInfoController {
    @Resource
    private AppInfoService appInfoService;
    @RequestMapping("list")
    @ResponseBody
    public Object getAppInfoList(){
        List<AppInfo> appInfoList=appInfoService.getAppInfoList();
        return appInfoList;
    }
    @RequestMapping("main")
    public Object index(Model model){
        List<AppInfo> appInfoList=appInfoService.getAppInfoList();
        model.addAttribute("appInfoList",appInfoList);
        return "index";
    }
    @RequestMapping("del")
    public Object del(@RequestParam Integer id){
        int result=appInfoService.delById(id);
        if(result>0){
            System.out.println("成功");
        }else{
            System.out.println("失败");
        }
        return "redirect:/appinfo/main";
    }
}
